//
//  WeeksGoalSetupView.swift
//  DaRings
//
//  Created by 魔样科技 on 2022/11/12.
//

import Foundation
import MYModule

class GoalSetupWeeksView: View {

    override func makeUI() {
        super.makeUI()
        
        self.addSubview(self.weeksGoalSwitchView)
        self.weeksGoalSwitchView.snp.makeConstraints { make in
            make.top.equalToSuperview()
            make.leading.trailing.equalToSuperview()
        }
        
        self.addSubview(self.weekView)
        self.weekView.snp.makeConstraints { make in
            make.top.equalTo(self.weeksGoalSwitchView.snp.bottom)
            make.leading.trailing.equalToSuperview()
        }
        
        self.addSubview(self.weekGoalView)
        self.weekGoalView.snp.makeConstraints { make in
            make.top.equalTo(self.weekView.snp.bottom)
            make.leading.trailing.equalToSuperview()
            make.bottom.equalToSuperview()
        }
    }
    
    public func bindModel(model: WeeksGoalModel) {
        self.weeksGoalSwitchView.switchView.setOn(isOn: model.isOpen)
        self.weekView.isHidden = !model.isOpen
        self.weekGoalView.isHidden = !model.isOpen
        self.weekView.bindModel(model.weeks)
        self.weekGoalView.bindModel(model: model.goalModel)
        
        self.weekView.returnDidselectClosure { weeks in
            model.weeks = weeks
        }
    }
    
    //MARK: - lazy load -
    public lazy var weeksGoalSwitchView: GoalSetupWeeksSwitchView = {
        let view = GoalSetupWeeksSwitchView()
        view.backgroundColor = .assist_FFFFFF
        return view
    }()
    
    public lazy var weekView: GoalSetupWeekDayView = {
        let view = GoalSetupWeekDayView()
        view.backgroundColor = .assist_FFFFFF
        return view
    }()
    
    public lazy var weekGoalView: GoalSetupNormalView = {
        let view = GoalSetupNormalView()
        view.backgroundColor = .assist_FFFFFF
        view.cornerRadius = 18
        return view
    }()
    
    
}

